// custom-tab-bar/index.js
const app = getApp()
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    active: 1,
    // list: app.globalData.datalist()
    list: []
  },

  /**
   * 组件的方法列表
   */
  created(){
  
  },
  methods: {
    onChange(event) {
      this.setData({ active: event.detail });
      wx.switchTab({
        url: this.data.list[event.detail].pagePath,
      });
    },
    init() {
      const page = getCurrentPages().pop();
      let urls = this.data.list.map(v => v.pagePath);
      let active =  urls.findIndex(v => v ===  `/${page.route}`)
      this.setData({active:active})
    },
    toggleMenu(role)
    {
      if(role == 2)
      {
        let list = app.globalData.datalist()
        const arr = list.slice(3,6)
        this.setData({list:arr})
      }else if(role == 0)
      {
        let list = app.globalData.datalist()
        const arr = list.slice(0,3)
        this.setData({list:arr,active:1})
      }
        
    }
  },
})